<template>
  <el-container>
    <el-header>
      <div class="header-content">
        建筑业从业人员继续教育考试系统
      </div>
    </el-header>
    <el-main v-loading="loading">
      <el-row type="flex" class="row-bg" justify="center" :gutter="12" style="align-items: center;height: 600px;">
        <el-col :span="6">
          <el-card shadow="always" class="custom-card">
            <div class="time" slot="header">
              成绩信息
            </div>
            <div style="min-height: 320px;">
              <el-row type="flex" justify="center" class="user-item">
                <el-col :span="20">{{ resultInfor && resultInfor.userName }}</el-col>
              </el-row>
              <el-row type="flex" justify="center" class="user-item" v-if="resultInfor && resultInfor.pass">
                <el-col :span="20">
                  恭喜您，本次考试成绩为
                  <span style="color: #67c23a;">{{ resultInfor && resultInfor.score || 0 }}</span>
                  分，合格
                </el-col>
              </el-row>
              <el-row type="flex" justify="center" class="user-item" v-else>
                <el-col :span="20">
                  很遗憾，您本次考试成绩为
                  <span style="color: red;">{{ resultInfor && resultInfor.score || 0 }}</span>
                  分，不合格
                </el-col>
              </el-row>
            </div>
          </el-card>
        </el-col>
      </el-row>
    </el-main>
    <el-footer>
      <span>技术支持：贵阳市金阳建设数据服务有限公司</span>
    </el-footer>
  </el-container>
</template>

<script>
  import request from '@/utils/request'
  export default {
    name: 'ExamResult',
    data() {
      return {
        Urls: {
          // 考试结果
          resultUrl: '/api/exam/record/result/',
        },
        examId: localStorage.getItem('examId'),
        resultInfor: {
          pass: 0,
          score: 0,
          userName: ''
        },
        loading: false,
      }
    },
    created() {
      this.getExamResult()
    },
    methods: {
      /**
       * 考试结果
       */
      getExamResult() {
        const _this = this
        _this.loading = true
        request({
          url: _this.Urls.resultUrl + _this.examId,
          method: 'get',
          data: {}
        }).then(res => {
          _this.loading = false
          if (res.code == 0) {
            _this.resultInfor = res.data
          } else{
            _this.$notify.error({
              message: res.msg
            })
          }
        })
      },
    }
  }
</script>

<style scoped="scoped">
  .el-container {
    height: 100vh;
    flex-direction: column;
  }

  .el-header, .el-footer {
      background-color: #B3C0D1;
      line-height: 60px;
    }
    .el-header {
      background-color: #fff;
    }
    .header-content {
      width: 90%;
      margin: 0 auto;
      color: #1a8cff;
      font-size: 24px;
    }
    .el-footer {
      font-weight: 400;
      text-align: center;
      background-color: #000;
      color: #fff;
    }
    .el-main {
      flex: 1;
      overflow: auto;
      background-color: #E9EEF3;
    }
    .clearfix:before,
    .clearfix:after {
        display: table;
        content: "";
    }
    .clearfix:after {
      clear: both
    }
    .qus-title-header {
      text-align: center;
    }
    .qus-title {
      font-weight: bold;
      font-size: 16px;
    }
    .qus-content {
      min-height: 400px;
    }
    .qus-info {
      margin-top: 12px;
      font-size: 14px;
    }
    .other-gutter {
      margin-top: 12px;
    }
    .time {
      text-align: center;
      font-size: 20px;
    }
    .qus-item {
      margin-bottom: 24px;
    }
    .qus-item-title {
      font-weight: bold;
      margin-bottom: 12px;
    }
    .qus-subject {
      margin-top: 16px;
      line-height: 24px;
    }
    .qus-option-content {
      margin-top: 24px;
    }
    .qus-option-content .el-radio {
      margin-bottom: 12px;
      display: block;
    }
    .qus-option-content .is-checked span:first-child {
      background-color: #409eff;
      color: #fff;
    }
    .qus-option-item {
      display: inline-block;
      padding: 4px;
      height: 24px;
      width: 24px;
      border-radius: 24px;
      border:1px solid #DCDFE6;
      vertical-align: middle;
      text-align: center;
      margin-right: 12px;
    }
    .qus-btn-group {
      margin-top: 48px;
      text-align: center;
    }
    .qus-btn-group button {
      width: 100px;
    }
    .qus-btn-group button:first-child {
      margin-right: 24px;
    }
    .sub-btn {
      width: 100%;
      text-align: center;
      padding-top: 32px;
    }
    .user-item {
      margin-bottom: 24px;
    }
    .user-title {
      text-align: right;
      color: #a3a49d;
    }
</style>
